package l2ft.gameserver.ai.FakePcs;

import l2ft.commons.util.Rnd;
import l2ft.gameserver.ai.MainFakePc;
import l2ft.gameserver.model.Creature;
import l2ft.gameserver.model.Skill;
import l2ft.gameserver.model.instances.NpcInstance;
import l2ft.gameserver.tables.SkillTable;

public class TankFakePc extends MainFakePc
{
	private static final int[][] uds = {{110,2}, {528, 1}, {368, 1}};
	public TankFakePc(NpcInstance actor) {
		super(actor);
	}

	@Override
	protected boolean createNewTask()
	{
		return defaultFightTask();
	}

	@Override
	protected boolean defaultFightTask() 
	{
		double actorHp = getActor().getCurrentHpPercents();
		Creature target;
		if((target = prepareTarget()) == null)
			return false;
		//getting distance
		double distance = getActor().getDistance(target);
		
		//if my hp is below 50%
		if(actorHp < 50)
		{
			//using ud
			int[] randomUD = uds[(int) Math.round(Math.random()*(uds.length-1))];
			return chooseTaskAndTargets(SkillTable.getInstance().getInfo(randomUD[0], randomUD[1]), getActor(), distance);
		}
		//if its hard, or i have chance to use debuff
		else if(target.isRaid() || Rnd.chance(getRateDEBUFF()))
		{
			Skill aggression = SkillTable.getInstance().getInfo(28, 49);
			Skill hateAura = SkillTable.getInstance().getInfo(18, 37);
			//using aggresion
			if(canUseSkill(aggression, target))
				return chooseTaskAndTargets(aggression, target, distance);
			//or hate aura
			else if(canUseSkill(hateAura, target))
				return chooseTaskAndTargets(hateAura, target, distance);
			//or normal attack
			else
				return chooseTaskAndTargets(null, target, distance);
		}
		//if its player or mob
		else
		{
			//if target isnt mage and i cant use stun
			if(!target.isMageClass() && !Rnd.chance(getRateSTUN()))
			{
				//Shield slam!
				Skill shieldSlam = SkillTable.getInstance().getInfo(353, 1);
				return chooseTaskAndTargets(shieldSlam, target, distance);
			}
			//using stun
			Skill shieldStun = SkillTable.getInstance().getInfo(92, 52);
			return chooseTaskAndTargets(shieldStun, target, distance);
		}
	}
	
	@Override
	public int getRatePHYS()
	{
		return 0;
	}

	@Override
	public int getRateDOT()
	{
		return 0;
	}

	@Override
	public int getRateDEBUFF()
	{
		return 50;
	}

	@Override
	public int getRateDAM()
	{
		return 0;
	}

	@Override
	public int getRateSTUN()
	{
		return 40;
	}

	@Override
	public int getRateBUFF()
	{
		return 50;
	}

	@Override
	public int getRateHEAL()
	{
		return 0;
	}
}
